import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
    state: () => ({
      jwttoken: ref(''),
      username: ref('请登录'),
      userId: ref(''),
      image : ref(''),
      article : ref(['']),
      types:ref(["test1","test2","test3","test"]),
      hadRead : ref([]),
      param:ref('')
    }),
  
    actions: {
      getJwtToken() {
        this.jwttoken = localStorage.getItem('jwttoken')
      }
      , 
      clearStyle(){
        const elements = document.getElementsByTagName('*')
        for (let i = 0; i < elements.length; i++) {
        elements[i].style.margin = '0'
        elements[i].style.padding = '0'
        elements[i].style.border = '0'
        elements[i].style.outline = '0'
        elements[i].style.fontSize = '100%'
        elements[i].style.verticalAlign = 'baseline'
        elements[i].style.background = 'transparent'
        }
      } ,
      clear(){
        this.jwttoken='',
        this.username='请登录',
        this.userId='',
        this.image ='',
        this.article=[''],
        this.param=''
      }
    }
  })